package com.qf.service.impl;

import com.qf.dao.AccountDao;
import com.qf.pojo.Account;
import com.qf.service.AccountService;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/9/28 15:59
 */
public class AccountServiceImpl implements AccountService {
    AccountDao accountDao;

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    @Override
    public void trans(String name, String name1, double money) {
        Account accountFrom = accountDao.selectByName(name);
        Account accountTo = accountDao.selectByName(name1);

        accountFrom.setMoney(accountFrom.getMoney()-money);
        accountTo.setMoney(accountTo.getMoney()+money);

        accountDao.update(accountFrom);
        System.out.println(1/0);
        accountDao.update(accountTo);
    }


}
